package modules

import (
	"gitee.com/williamguang/verify/lib"
	"gitee.com/williamguang/verify/models"
	"github.com/gin-gonic/gin"
	"net/http"
)

func Hi(c *gin.Context) {
	c.String(http.StatusCreated, "hi sidecar")
}
func ChangePwd4Ftp(c *gin.Context) {
	req := &models.FtpChangePwdReq{}
	err := c.BindJSON(req)
	if err != nil {
		lib.Logger.Error(err)
		c.String(http.StatusInternalServerError, "input parameter not valid")
		return
	}

	cmdResult, err := ExecuteCmd("/bin/bash", "-c", "echo "+req.FtpUser+":"+req.FtpPassword+" | chpasswd")
	if err != nil {
		lib.Logger.Error(err)
		c.String(http.StatusInternalServerError, "reload failed :"+err.Error())
		return
	}
	c.String(http.StatusOK, cmdResult)

}
